package com.qf.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.WmsTl;
import com.qf.service.WmsTlService;
import com.qf.until.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * --- 愿许秋风知我意，赐我十亿人民币 ---
 *
 * @author HeErkang
 * @date 2024/7/23
 * @desc --- 万一赢了呢？ ---
 * @desc --- 今日课程 ---
 */
@RestController
@RequestMapping("/wms/tl/")
public class WmsTlController {

    @Autowired
    private WmsTlService service;

    /**
     * 查询全部计量单位
     * 分页和模糊搜索
     */

    @GetMapping("/list")
    public R findAll(@RequestParam HashMap<String, String> map) {
        int pageNum = Integer.parseInt(map.get("pageNum"));
        int pageSize = Integer.parseInt(map.get("pageSize"));
        PageHelper.startPage(pageNum,pageSize);

        List<WmsTl> list = service.findAll(map);
        PageInfo<WmsTl> info = new PageInfo<>(list);
        return R.ok(info);
    }

    // 删除
    @GetMapping("/del")
    public R deleteById(int id) {
        System.out.println(id);
        boolean isOk = service.deleteById(id);
        return R.ok(isOk);
    }
}
